import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _isUndefined from "lodash/isUndefined";
import _isEmpty from "lodash/isEmpty";
var _excluded = ["categoryCode"];

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _class, _class2;

/**
 * MessageTemplate - 消息模板明细维护
 * @date: 2018-7-26

 */
import React, { PureComponent } from 'react';
import { Cascader, Col, Form, Input, Row, Spin } from 'antd';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { Bind } from 'lodash-decorators';
import classNames from 'classnames';
import Switch from 'components/Switch';
import { Content, Header } from 'components/Page'; // import TinymceEditor from 'components/TinymceEditor';

import Lov from 'components/Lov';
import { Button as ButtonPermission } from 'components/Permission';
import notification from 'utils/notification';
import intl from 'utils/intl';
import formatterCollections from 'utils/intl/formatterCollections';
import { isTenantRoleLevel } from 'utils/utils';
import { CODE_UPPER } from 'utils/regExp';
import { EDIT_FORM_ROW_LAYOUT, FORM_COL_3_LAYOUT, ROW_HALF_WRITE_ONLY_CLASSNAME, ROW_LAST_CLASSNAME, ROW_READ_ONLY_CLASSNAME, ROW_WRITE_ONLY_CLASSNAME, SEARCH_FORM_CLASSNAME } from 'utils/constants';
import StaticTextEditor from "./StaticTextEditor";
import Drawer from "./Drawer";
import styles from "./index.less?modules";
var formItemLayout = {
  labelCol: {
    span: 8
  },
  wrapperCol: {
    span: 16
  }
};
var formItemLayout3 = {
  labelCol: {
    span: 3
  },
  wrapperCol: {
    span: 21
  }
};

function getFieldsValueByWrappedComponentRef(ref) {
  if (ref.current) {
    var form = ref.current.props.form;
    return form.getFieldsValue();
  }

  return {};
}
/**
 * 消息模板明细组件
 * @extends {Component} - React.Component
 * @reactProps {Object} [location={}] - 当前路由信息
 * @reactProps {Object} [match={}] - react-router match路由信息
 * @reactProps {!Object} messageTemplate - 数据源
 * @reactProps {!boolean} loading - 数据加载是否完成
 * @reactProps {!boolean} detailLoading - 明细数据加载
 * @reactProps {Object} form - 表单对象
 * @reactProps {Function} [dispatch= e => e] - redux dispatch方法
 * @return React.element
 */


var Detail = (_dec = connect(function (_ref) {
  var messageTemplate = _ref.messageTemplate,
      loading = _ref.loading;
  return {
    messageTemplate: messageTemplate,
    loading: loading.effects['messageTemplate/updateTemplate'] || loading.effects['messageTemplate/addTemplate'],
    detailLoading: !!loading.effects['messageTemplate/fetchCopyDetail'] || !!loading.effects['messageTemplate/fetchDetail'],
    detailParaLoading: loading.effects['messageTemplate/fetchDetailPara'] || loading.effects['messageTemplate/editPara'] || loading.effects['messageTemplate/deletePara'],
    detailParaInitLoading: loading.effects['messageTemplate/initPara'],
    tenantRoleLevel: isTenantRoleLevel()
  };
}), _dec2 = Form.create({
  fieldNameProp: null
}), _dec3 = formatterCollections({
  code: ['cmsg.messageTemplate', 'entity.tenant', 'entity.lang']
}), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), _dec13 = Bind(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = /*#__PURE__*/function (_PureComponent) {
  _inherits(Detail, _PureComponent);

  var _super = _createSuper(Detail);

  function Detail(props) {
    var _this;

    _classCallCheck(this, Detail);

    _this = _super.call(this, props);
    _this.filterFormRef = React.createRef();
    _this.staticTextEditor = React.createRef();
    var _this$props = _this.props,
        templateContent = _this$props.messageTemplate.detail.templateContent,
        _this$props$match$par = _this$props.match.params,
        type = _this$props$match$par.type,
        id = _this$props$match$par.id;
    _this.state = {
      flag: false,
      spinning: !_isUndefined(id) && type !== 'copy',
      prevContent: templateContent,
      modalVisible: false
    };
    return _this;
  }
  /**
   * componentDidMount
   * render()调用后获取页面数据信息
   */


  _createClass(Detail, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.handleSearch();
    }
  }, {
    key: "handleSearch",
    value:
    /**
     * 查询
     */
    function handleSearch() {
      var _this$props2 = this.props,
          dispatch = _this$props2.dispatch,
          match = _this$props2.match,
          _this$props2$history$ = _this$props2.history.location.payload,
          payload = _this$props2$history$ === void 0 ? {} : _this$props2$history$;
      var templateId = payload.templateId,
          isCopy = payload.isCopy;
      var id = match.params.id;

      if (!_isUndefined(id) || isCopy) {
        dispatch({
          type: isCopy ? 'messageTemplate/fetchCopyDetail' : 'messageTemplate/fetchDetail',
          payload: {
            templateId: isCopy ? templateId : id
          }
        });
      }

      dispatch({
        type: 'messageTemplate/fetchType'
      });
    }
    /**
     * 查询模板参数
     */

  }, {
    key: "handleSearchArg",
    value: function handleSearchArg() {
      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var _this$props3 = this.props,
          dispatch = _this$props3.dispatch,
          match = _this$props3.match;
      var id = match.params.id;
      var page = params.page;
      var fieldValues = getFieldsValueByWrappedComponentRef(this.filterFormRef);
      dispatch({
        type: 'messageTemplate/fetchDetailPara',
        payload: {
          argName: fieldValues.argName,
          templateId: id,
          page: page
        }
      });
    }
    /**
     * 模板参数初始化
     */

  }, {
    key: "handleInit",
    value: function handleInit() {
      var _this2 = this;

      var _this$props4 = this.props,
          dispatch = _this$props4.dispatch,
          match = _this$props4.match;
      var id = match.params.id;
      dispatch({
        type: 'messageTemplate/initPara',
        payload: {
          templateId: id
        }
      }).then(function (res) {
        if (res) {
          _this2.handleSearchArg();
        }
      });
    }
    /**
     * 模板参数编辑
     */

  }, {
    key: "handleEdit",
    value: function handleEdit(data, flag) {
      var _this$props5 = this.props,
          dispatch = _this$props5.dispatch,
          _this$props5$messageT = _this$props5.messageTemplate;
      _this$props5$messageT = _this$props5$messageT === void 0 ? {} : _this$props5$messageT;
      var _this$props5$messageT2 = _this$props5$messageT.paraList,
          paraList = _this$props5$messageT2 === void 0 ? [] : _this$props5$messageT2;
      var newList = paraList.map(function (item) {
        if (data.argId === item.argId) {
          return _objectSpread(_objectSpread({}, item), {}, {
            _status: flag ? 'update' : ''
          });
        } else {
          return _objectSpread(_objectSpread({}, item), {}, {
            _status: ''
          });
        }
      });
      dispatch({
        type: 'messageTemplate/updateState',
        payload: {
          paraList: newList
        }
      });
    }
    /**
     * 模板参数删除
     */

  }, {
    key: "handleDelete",
    value: function handleDelete(data) {
      var _this3 = this;

      var _this$props6 = this.props,
          dispatch = _this$props6.dispatch,
          _this$props6$messageT = _this$props6.messageTemplate.paraPagination,
          paraPagination = _this$props6$messageT === void 0 ? {} : _this$props6$messageT;
      var params = data;
      delete params._status;
      delete params.$form;
      dispatch({
        type: 'messageTemplate/deletePara',
        payload: data
      }).then(function (res) {
        if (res) {
          _this3.handleSearchArg({
            page: paraPagination
          });
        }
      });
    }
    /**
     * 模板参数保存
     */

  }, {
    key: "handleSave",
    value: function handleSave(record) {
      var _this4 = this;

      var _this$props7 = this.props,
          dispatch = _this$props7.dispatch,
          _this$props7$messageT = _this$props7.messageTemplate.paraPagination,
          paraPagination = _this$props7$messageT === void 0 ? [] : _this$props7$messageT;
      var temp = record;
      delete temp._status;
      dispatch({
        type: 'messageTemplate/editPara',
        payload: temp
      }).then(function (res) {
        if (res) {
          _this4.handleSearchArg({
            page: paraPagination
          });
        }
      });
    }
    /**
     * 保存
     */

  }, {
    key: "handelSaveOption",
    value: function handelSaveOption() {
      var _this5 = this;

      var _this$props8 = this.props,
          form = _this$props8.form,
          dispatch = _this$props8.dispatch,
          messageTemplate = _this$props8.messageTemplate,
          tempType = _this$props8.match.params;
      var _messageTemplate$deta = messageTemplate.detail,
          detail = _messageTemplate$deta === void 0 ? {} : _messageTemplate$deta;
      var templateContent = '';
      form.validateFields(function (err, values) {
        if (!err) {
          _this5.getEditData().then(function (data) {
            if (data.text !== undefined) {
              templateContent = data.text;

              if (templateContent === '' || _isUndefined(templateContent)) {
                _this5.setState({
                  flag: true
                });

                return;
              } // 校验通过，进行保存操作


              var type = 'messageTemplate/updateTemplate'; // 默认操作：更新

              if (!detail.templateId || tempType.type) {
                // 新建
                type = 'messageTemplate/addTemplate';
              }

              var categoryCode = values.categoryCode,
                  others = _objectWithoutProperties(values, _excluded);

              dispatch({
                type: type,
                payload: _objectSpread(_objectSpread(_objectSpread({}, detail), others), {}, {
                  messageCategoryCode: categoryCode[0],
                  messageSubcategoryCode: categoryCode[1],
                  templateContent: templateContent,
                  lang: 'zh_CN'
                })
              }).then(function (res) {
                if (res) {
                  notification.success();

                  if (!detail.templateId) {
                    dispatch(routerRedux.push({
                      pathname: "/cmsg/message-template/detail/".concat(res.templateId)
                    }));
                  }

                  dispatch({
                    type: 'messageTemplate/updateState',
                    payload: {
                      detail: res
                    }
                  });
                }
              });

              _this5.setState({
                flag: false
              });
            }
          });
        } else {
          _this5.setState({
            flag: false
          });
        }
      });
    }
  }, {
    key: "handleOpen",
    value: function handleOpen() {
      var dispatch = this.props.dispatch;
      var modalVisible = this.state.modalVisible;

      if (modalVisible) {
        dispatch({
          type: 'messageTemplate/updateState',
          payload: {
            paraList: [],
            paraPagination: {}
          }
        });
      } else {
        this.handleSearchArg();
      }

      this.setState({
        modalVisible: !modalVisible
      });
    }
  }, {
    key: "onRichTextEditorChange",
    value: function onRichTextEditorChange(dataSource) {
      var _this$props9 = this.props,
          dispatch = _this$props9.dispatch,
          detail = _this$props9.messageTemplate.detail;
      dispatch({
        type: 'messageTemplate/updateState',
        payload: {
          detail: _objectSpread(_objectSpread({}, detail), {}, {
            templateContent: dataSource
          })
        }
      });

      if (dataSource === '') {
        this.setState({
          flag: true
        });
      } else {
        this.setState({
          flag: false
        });
      }
    }
  }, {
    key: "getEditData",
    value: function getEditData() {
      var _this6 = this;

      if (!this.staticTextEditor) {
        return Promise.reject();
      }

      return new Promise(function (resolve, reject) {
        var form = _this6.props.form;
        form.validateFields(function (err, fieldsValue) {
          if (err) {
            reject();
          } else {
            var editor = (_this6.staticTextEditor.staticTextEditor || {}).current.editor;

            if (!editor || !editor.getData()) {
              return notification.warning({
                message: intl.get('cmsg.messageTemplate.view.message.alert.contentRequired').d('请输入静态文本内容')
              });
            }

            resolve(_objectSpread(_objectSpread({}, fieldsValue), {}, {
              text: editor.getData()
            }));
          }
        });
      });
    }
    /**
     * render
     * @returns React.element
     */

  }, {
    key: "render",
    value: function render() {
      var _classNames,
          _this7 = this;

      var _this$props10 = this.props,
          _this$props10$form = _this$props10.form,
          getFieldDecorator = _this$props10$form.getFieldDecorator,
          getFieldValue = _this$props10$form.getFieldValue,
          messageTemplate = _this$props10.messageTemplate,
          loading = _this$props10.loading,
          detailLoading = _this$props10.detailLoading,
          detailParaLoading = _this$props10.detailParaLoading,
          detailParaInitLoading = _this$props10.detailParaInitLoading,
          tenantRoleLevel = _this$props10.tenantRoleLevel,
          _this$props10$match = _this$props10.match,
          id = _this$props10$match.params.id,
          path = _this$props10$match.path,
          _this$props10$history = _this$props10.history.location.payload,
          payload = _this$props10$history === void 0 ? {} : _this$props10$history;
      var _messageTemplate$cate = messageTemplate.categoryTree,
          categoryTree = _messageTemplate$cate === void 0 ? [] : _messageTemplate$cate,
          _messageTemplate$para = messageTemplate.paraList,
          paraList = _messageTemplate$para === void 0 ? [] : _messageTemplate$para,
          _messageTemplate$para2 = messageTemplate.paraPagination,
          paraPagination = _messageTemplate$para2 === void 0 ? {} : _messageTemplate$para2,
          _messageTemplate$deta2 = messageTemplate.detail,
          detail = _messageTemplate$deta2 === void 0 ? {} : _messageTemplate$deta2,
          _messageTemplate$copy = messageTemplate.copyDetail,
          copyDetail = _messageTemplate$copy === void 0 ? {} : _messageTemplate$copy;
      var isCopy = payload.isCopy;
      var _this$state = this.state,
          flag = _this$state.flag,
          spinning = _this$state.spinning,
          prevContent = _this$state.prevContent,
          modalVisible = _this$state.modalVisible;
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
        title: intl.get('cmsg.messageTemplate.view.message.title.detail').d('消息模板明细'),
        backPath: "/cmsg/message-template/list"
      }, /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.save"),
          type: 'button',
          meaning: '消息模板-保存'
        }],
        onClick: this.handelSaveOption,
        type: "primary",
        icon: "save",
        loading: loading
      }, intl.get('cpaas.common.button.save').d('保存')), /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.params"),
          type: 'button',
          meaning: '消息模板-查看模板参数'
        }],
        onClick: this.handleOpen,
        icon: "eye",
        disabled: _isEmpty(id) || loading
      }, intl.get('cmsg.messageTemplate.model.template.templateParam').d('模板参数'))), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(Spin, {
        spinning: spinning ? detailLoading : null
      }, /*#__PURE__*/React.createElement(Form, {
        className: classNames(styles['template-form'], SEARCH_FORM_CLASSNAME)
      }, !tenantRoleLevel && /*#__PURE__*/React.createElement(Row, Object.assign({}, EDIT_FORM_ROW_LAYOUT, {
        className: classNames((_classNames = {}, _defineProperty(_classNames, ROW_WRITE_ONLY_CLASSNAME, _isUndefined(detail.tenantId)), _defineProperty(_classNames, ROW_READ_ONLY_CLASSNAME, !_isUndefined(detail.tenantId)), _classNames))
      }), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: intl.get("entity.tenant.tag").d('租户'),
        required: _isUndefined(detail.tenantId)
      }), getFieldDecorator('tenantId', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get("entity.tenant.tag").d('租户')
          })
        }],
        initialValue: detail.tenantId
      })(_isUndefined(detail.tenantId) ? /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.TENANT",
        textValue: detail.tenantName
      }) : /*#__PURE__*/React.createElement(React.Fragment, null, detail.tenantName)))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: intl.get('cmsg.messageTemplate.model.template.templateTitle').d('消息模板标题')
      }), getFieldDecorator('templateTitle', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cmsg.messageTemplate.model.template.templateTitle').d('消息模板标题')
          })
        }],
        initialValue: isCopy ? copyDetail.templateTitle : detail.templateTitle
      })( /*#__PURE__*/React.createElement(Input, null))))), /*#__PURE__*/React.createElement(Row, EDIT_FORM_ROW_LAYOUT, /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: intl.get('cmsg.messageTemplate.model.template.templateCode').d('消息模板代码'),
        required: _isUndefined(detail.templateCode)
      }), getFieldDecorator('templateCode', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cmsg.messageTemplate.model.template.templateCode').d('消息模板代码')
          })
        }, {
          pattern: CODE_UPPER,
          message: intl.get('cpaas.common.validation.codeUpper').d('全大写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”')
        }],
        initialValue: isCopy ? copyDetail.templateCode : detail.templateCode
      })(_isUndefined(detail.templateCode) || isCopy ? /*#__PURE__*/React.createElement(Input, {
        trim: true,
        typeCase: "upper",
        inputChinese: false
      }) : /*#__PURE__*/React.createElement("span", {
        style: {
          overflowWrap: 'break-word'
        }
      }, detail.templateCode)))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: intl.get('cmsg.messageTemplate.model.template.templateName').d('消息模板名称')
      }), getFieldDecorator('templateName', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cmsg.messageTemplate.model.template.templateName').d('消息模板名称')
          })
        }],
        initialValue: isCopy ? copyDetail.templateName : detail.templateName
      })( /*#__PURE__*/React.createElement(Input, null))))), /*#__PURE__*/React.createElement(Row, EDIT_FORM_ROW_LAYOUT, /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: intl.get('cmsg.messageTemplate.model.template.externalCode').d('外部编码')
      }), getFieldDecorator('externalCode', {
        rules: [{
          required: getFieldValue('templateTypeCode') === 'SMS',
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cmsg.messageTemplate.model.template.externalCode').d('外部编码')
          })
        }],
        initialValue: detail.externalCode
      })( /*#__PURE__*/React.createElement(Input, {
        trim: true
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: intl.get('cmsg.messageTemplate.model.template.subcategoryCode').d('消息子类型')
      }), getFieldDecorator('categoryCode', {
        initialValue: [detail.messageCategoryCode, detail.messageSubcategoryCode]
      })( /*#__PURE__*/React.createElement(Cascader, {
        fieldNames: {
          label: 'meaning',
          value: 'value',
          children: 'children'
        },
        options: categoryTree,
        expandTrigger: "hover",
        placeholder: ""
      }))))), /*#__PURE__*/React.createElement(Row, EDIT_FORM_ROW_LAYOUT, /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: intl.get('cpaas.common.status.enable').d('启用')
      }), getFieldDecorator('enabledFlag', {
        initialValue: _isUndefined(detail.enabledFlag) ? 1 : detail.enabledFlag
      })( /*#__PURE__*/React.createElement(Switch, null))))), /*#__PURE__*/React.createElement(Row, Object.assign({}, EDIT_FORM_ROW_LAYOUT, {
        className: classNames(styles['row-item2'], ROW_HALF_WRITE_ONLY_CLASSNAME)
      }), /*#__PURE__*/React.createElement(Col, {
        style: {
          width: '82%'
        }
      }, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout3, {
        label: /*#__PURE__*/React.createElement("span", {
          className: styles.templateContentLabel
        }, intl.get('cmsg.messageTemplate.model.template.templateContent').d('消息模板内容')),
        className: flag ? styles.templateContent : ''
      }), !detailLoading && ((isCopy ? false : id === undefined) || copyDetail.templateContent || prevContent) && /*#__PURE__*/React.createElement(StaticTextEditor, {
        key: id === undefined ? 'new' : id,
        content: // eslint-disable-next-line no-nested-ternary
        id === undefined ? isCopy ? copyDetail.templateContent : undefined : prevContent,
        readOnly: false,
        onRef: function onRef(staticTextEditor) {
          _this7.staticTextEditor = staticTextEditor;
        }
      }), flag ? /*#__PURE__*/React.createElement("span", {
        className: styles.templateContentError
      }, intl.get('cpaas.common.validation.notNull', {
        name: intl.get("cmsg.messageTemplate.model.template.templateContent").d('消息模板内容')
      })) : null))), /*#__PURE__*/React.createElement(Row, Object.assign({}, EDIT_FORM_ROW_LAYOUT, {
        className: classNames(styles['row-item2'], ROW_HALF_WRITE_ONLY_CLASSNAME, ROW_LAST_CLASSNAME)
      }), /*#__PURE__*/React.createElement(Col, {
        style: {
          width: '82%'
        }
      }, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout3, {
        label: intl.get('cmsg.messageTemplate.model.template.sqlValue').d('SQL')
      }), getFieldDecorator('sqlValue', {
        initialValue: isCopy ? copyDetail.sqlValue : detail.sqlValue
      })( /*#__PURE__*/React.createElement(Input.TextArea, {
        autosize: {
          minRows: 5,
          maxRows: 7
        }
      })))))), /*#__PURE__*/React.createElement(Drawer, {
        visible: modalVisible,
        id: id,
        path: path,
        dataSource: paraList,
        pagination: paraPagination,
        loading: detailParaInitLoading,
        fetchLoading: detailParaLoading,
        wrappedComponentRef: this.filterFormRef,
        onInit: this.handleInit,
        onCancel: this.handleOpen,
        onEdit: this.handleEdit,
        onDelete: this.handleDelete,
        onSearch: this.handleSearchArg,
        onOk: this.handleSave
      }))));
    }
  }], [{
    key: "getDerivedStateFromProps",
    value: function getDerivedStateFromProps(nextProps, prevState) {
      var templateContent = nextProps.messageTemplate.detail.templateContent;

      if ((templateContent || '') !== prevState.prevContent) {
        return {
          prevContent: templateContent || ''
        };
      }

      return null;
    }
  }]);

  return Detail;
}(PureComponent), (_applyDecoratedDescriptor(_class2.prototype, "handleSearch", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearch"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSearchArg", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearchArg"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleInit", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "handleInit"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleEdit", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "handleEdit"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDelete", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDelete"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSave", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSave"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handelSaveOption", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "handelSaveOption"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleOpen", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "handleOpen"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "onRichTextEditorChange", [_dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "onRichTextEditorChange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "getEditData", [_dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "getEditData"), _class2.prototype)), _class2)) || _class) || _class) || _class);
export { Detail as default };